package com.feidian.helper.net;

import java.io.IOException;
import java.io.UnsupportedEncodingException;

import Decoder.BASE64Decoder;
import Decoder.BASE64Encoder;

import com.feidian.helper.util.Constant;

public class Base64 {

	public static String encode(String input) {
		byte[] b = null;
		String value = null;
		try {
			b = input.getBytes(Constant.ENCODER);
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		if (b != null) {
			value = new BASE64Encoder().encode(b);
		}
		return value;
	}

	public static String decode(String input) {
		byte[] b = null;
		try {
			b = new BASE64Decoder().decodeBuffer(input);
			return new String(b, Constant.ENCODER);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return "";

	}

}
